package com.study.happystudy.tool;

import java.security.SecureRandom;
import java.util.Base64;

public class SaltGenerator {
    public static String generateSalt(int length){
        SecureRandom random=new SecureRandom();
        try{
            random=SecureRandom.getInstance("SHA1PRNG");
            random.setSeed(System.currentTimeMillis());
        }catch (Exception e){
            e.printStackTrace();
        }
        byte[] saltBytes=new byte[length];
        random.nextBytes(saltBytes);
        return Base64.getEncoder().encodeToString(saltBytes);
    }
}
